/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package shellCommands;

import Sessions.EcomAdminRemote;
import Sessions.EcomCustomersRemote;
import java.util.StringTokenizer;

/**
 *
 * @author SOGOBA
 */
public class CurrencyCommand implements InterShell{
 private ContextCommande cxtCmd;

    public CurrencyCommand (ContextCommande ContextCommand){
          cxtCmd =  ContextCommand;

    }

    @Override
    public Commands getName() {
        return Commands.currency;
    }

    @Override
    public String getShortDescription() {
        return "output EUR|FRF|USD|GB| change the currency";
    }

    @Override
    public void execute(String cmd,EcomAdminRemote ecomAdmin,EcomCustomersRemote ecomCust) {
        StringTokenizer st = new StringTokenizer(cmd, " ");
        // Ignore the command name.
        st.nextToken();
        // There should be at least one string.
        if (st.countTokens()==1){
            String str=st.nextToken().trim();
            switch (str) {
                case "EUR":
                    cxtCmd.setVar("currency", "EUR");
                    break;
                case "FRF":
                    cxtCmd.setVar("language", "FRF"); 
                    break;
                case "USD":
                    cxtCmd.setVar("language", "USD");
                    break;
                case "GBP":
                    cxtCmd.setVar("language", "GBP");
                    break;
                case "CAD":
                    cxtCmd.setVar("language", "CAD");
                    break;
                case "AUD":
                    cxtCmd.setVar("language", "AUD"); 
                    break;
                    case "CHF":
                    cxtCmd.setVar("language", "CHF");
                    break;
                case "RUB":
                    cxtCmd.setVar("language", "RUB");
                    break;
                case "CYN":
                    cxtCmd.setVar("language", "CYN");
                    break;
                     case "ZAR":
                    cxtCmd.setVar("language", "ZAR");
                    break;
                case "MXN":
                    cxtCmd.setVar("language", "MXN");
                    break;
            }
          System.out.println("the currency is correctly change to "+str);
            }
        else {
            System.out.println("Incorrect number of arguments");
        }
    }
}
